/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.upn.sigemfi.rec.be;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Diego
 */
@Entity
@Table(name = "REC_CARTERA")
@NamedQueries({@NamedQuery(name = "Cartera.findAll", query = "SELECT c FROM Cartera c"), @NamedQuery(name = "Cartera.findByIdCartera", query = "SELECT c FROM Cartera c WHERE c.idCartera = :idCartera"), @NamedQuery(name = "Cartera.findByNombre", query = "SELECT c FROM Cartera c WHERE c.nombre = :nombre"), @NamedQuery(name = "Cartera.findByDescripcion", query = "SELECT c FROM Cartera c WHERE c.descripcion = :descripcion")})
public class Cartera implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID_CARTERA", nullable = false)
    private Long idCartera;
    @Column(name = "NOMBRE", length = 10)
    private String nombre;
    @Column(name = "DESCRIPCION", length = 50)
    private String descripcion;
    @OneToMany(mappedBy = "fidRecCartera", fetch = FetchType.EAGER)
    private List<Credito> creditoCollection;

    public Cartera() {
    }

    public Cartera(Long idCartera) {
        this.idCartera = idCartera;
    }

    public Long getIdCartera() {
        return idCartera;
    }

    public void setIdCartera(Long idCartera) {
        this.idCartera = idCartera;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public List<Credito> getCreditoCollection() {
        return creditoCollection;
    }

    public void setCreditoCollection(List<Credito> creditoCollection) {
        this.creditoCollection = creditoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCartera != null ? idCartera.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cartera)) {
            return false;
        }
        Cartera other = (Cartera) object;
        if ((this.idCartera == null && other.idCartera != null) || (this.idCartera != null && !this.idCartera.equals(other.idCartera))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.upn.sigemfi.rec.be.Cartera[idCartera=" + idCartera + "]";
    }

}
